/*
 * pwm.c
 *
 *  Created on: Feb 27, 2013
 *      Author: jimmy
 */


#include "pwm.h"

void pwm_init()
{

//MCF_PWM_PWME = 0; // Disable all PWM ports for alignment setting

MCF_PWM_PWMCAE = 0x7F; // left align for PWM7

//MCF_PWM_PWME = 0x80; // PWM7 enabled with all others off	


MCF_PWM_PWMPOL &= 0x7F; // set polarity to low on PWM7

MCF_PWM_PWMCLK |= 0x80; // Using clock SB on PWM7

MCF_PWM_PWMPRCLK &= 0x00; // prescaler set to divide by 1

MCF_PWM_PWMSCLB = 0xA2;

MCF_PWM_PWMCTL &= 0x7C; // set PWM7 and PWM6 as separate

//MCF_PWM_PWMPER7 = 0xFA;
MCF_PWM_PWMPER7 = 0x15;
MCF_PWM_PWMDTY7 = 0x04;

//MCF_PWM_PWMDTY7 = 0xBC;

}


void set_duration()
{
}

void play_note()
{
	MCF_PWM_PWME = 0x80; // PWM7 enabled with all others off
}

void end_note()
{
	MCF_PWM_PWME = 0x00;
}

